cmake_minimum_required(VERSION 3.10)
project(vdb_etcd VERSION 1.0)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 设置编译器选项
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")

# 查找所需的包
find_package(PkgConfig)
find_package(spdlog REQUIRED)
find_package(Threads REQUIRED)
find_package(jwt-cpp CONFIG REQUIRED)

# 包含目录
include_directories(/usr/local/include)

# 链接目录
link_directories(/usr/local/lib64)

# 创建logger库
add_library(logger
    logger.cc
)

target_link_libraries(logger 
    spdlog::spdlog
)

# 创建master_server库
add_library(master_server
    master_server.cpp
)

target_link_libraries(master_server
    logger
    etcd-cpp-api
    cpprest
    curl
    pthread
)

# 创建proxy_server库
add_library(proxy_server
    proxy_server.cpp
)

target_link_libraries(proxy_server
    logger
    etcd-cpp-api
    cpprest
    curl
    pthread
    jwt-cpp::jwt-cpp
)

# 编译vdb_server_master可执行文件
add_executable(vdb_server_master
    vdb_server_master.cpp
)

target_link_libraries(vdb_server_master
    master_server
    logger
    etcd-cpp-api
    cpprest
    curl
    pthread
    fmt
)

# 编译vdb_server_proxy可执行文件
add_executable(vdb_server_proxy
    vdb_server_proxy.cpp
)

target_link_libraries(vdb_server_proxy
    proxy_server
    logger
    etcd-cpp-api
    cpprest
    curl
    pthread
    fmt
    jwt-cpp::jwt-cpp
)